package com.wc.codeforces.总结题.A_TRUE_Battle;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/31 0:18
 * @description https://codeforces.com/contest/2030/problem/C
 */
public class Main {
    /**
     * 思路：
     * 先是Alice 放
     * 因为是总的计算时候先 & 运算 后 | 运算<p>
     * 所以如果两边有 1, 直接在这个 1旁边放一个 | Alice就必赢了<p>
     * 或者有两个相邻的 11, 那就可以通过两次在同一个 1 的两旁放 |, 也是必赢<p>
     * 其他方式都赢不了, 1 一定会被0吞掉<p>
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static char[] cs = new char[N];
    static int n;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            cs = (" " + sc.next()).toCharArray();
            boolean res = false;
            res = cs[1] == '1' || cs[n] == '1';
            for (int i = 2; i <= n; i++) {
                res |= cs[i] == '1' && cs[i - 1] == '1';
            }
            if (res) out.println("YES");
            else out.println("NO");
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
